package com.whu.waterworks.action;

import com.opensymphony.xwork2.ActionSupport;
import com.whu.waterworks.model.TWaterplantdataHis;
import com.whu.waterworks.model.TWaterplantdataId;
import com.whu.waterworks.service.WaterPlantDataService;

public class SaveWaterPlantData extends ActionSupport{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String waterPlantCode;
	private String time;
	private String value;
	private String type;
	
	private String result;//返回的结果
	
	private WaterPlantDataService waterPlantDataService;

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		TWaterplantdataHis tWaterplantdataHis = new TWaterplantdataHis();
		TWaterplantdataId tid = new TWaterplantdataId();
		tid.setWaterPlantNum(waterPlantCode);
		tid.setTime(time);
		tWaterplantdataHis.setId(tid);
		if(type.contains("压力"))
		{
			tWaterplantdataHis.setPressureValue(value);
		}
		else if(type.contains("供水量"))
		{
			tWaterplantdataHis.setTotalSupplyFlow(value);
		}
		else if(type.contains("浊度"))
		{
			tWaterplantdataHis.setTurbidity(value);
		}
		else if(type.contains("余氯"))
		{
			tWaterplantdataHis.setChlorineOut(value);
		}
		else if(type.contains("电流"))
		{
			tWaterplantdataHis.setaElectric(value);
		}
		else if(type.contains("电压"))
		{
			tWaterplantdataHis.setVoltage(value);
		}
		else if(type.contains("电量"))
		{
			tWaterplantdataHis.setPower(value);
		}
		else if(type.contains("频率"))
		{
			tWaterplantdataHis.setFrequency1(value);
		}
		else if(type.contains("转速"))
		{
			tWaterplantdataHis.setRotatingSpeed1(value);
		}
		else if(type.contains("清水池液位"))
		{
			tWaterplantdataHis.setWaterLevel(value);
		}
		else if(type.contains("流量1"))
		{
			tWaterplantdataHis.setFlow1(value);
		}
		else if(type.contains("流量2"))
		{
			tWaterplantdataHis.setFlow2(value);
		}
		else if(type.contains("流量3"))
		{
			tWaterplantdataHis.setFlow3(value);
		}
		else if(type.contains("流量4"))
		{
			tWaterplantdataHis.setFlow4(value);
		}
		else if(type.contains("流量5"))
		{
			tWaterplantdataHis.setFlow5(value);
		}
		else if(type.contains("流量6"))
		{
			tWaterplantdataHis.setFlow6(value);
		}
		if(waterPlantDataService.saveWaterPlantData(tWaterplantdataHis))
		{
			result="SUCCESS";
		}
		else {
			result="FAIL";
		}
		return super.execute();
	}
	
	public String getWaterPlantCode() {
		return waterPlantCode;
	}

	public void setWaterPlantCode(String waterPlantCode) {
		this.waterPlantCode = waterPlantCode;
	}

	public String getTime() {
		return time;
	}

	public void setTime(String time) {
		this.time = time;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}

	public WaterPlantDataService getWaterPlantDataService() {
		return waterPlantDataService;
	}

	public void setWaterPlantDataService(WaterPlantDataService waterPlantDataService) {
		this.waterPlantDataService = waterPlantDataService;
	}

	
	
	

}
